import React from "react";
import {
  BrowserRouter,
  Route,
  Redirect,
  Switch,
  withRouter,
} from "react-router-dom";
function AuthRoute(props) {
  const { path, component, isAuth } = props;
  const token = window.localStorage.getItem("token");
  console.log(token);
  if (!isAuth || token) {
    return <Route {...props} />;
  }
  return <Redirect to={"/login?" + path} />;
}

export default withRouter(AuthRoute);
